@extends("admin::layouts.master")


@section("content")

    {{--我是后台加载角色模板--}}



    <div class="col-lg-12">
        <div class="card card-table">
            <div class="card-header">
                角色管理
                <div class="mt-2">




                    <button type="button" class="btn btn-primary">
                        角色列表
                    </button>
                    <button data-toggle="modal" data-target="#formuser" type="button" class="btn btn-primary">
                        添加角色
                    </button>




                    @component("components.modal",['title'=>'添加角色','url'=>'/admin/role','id'=>'formuser','method'=>'POST'])

                        <div class="form-group">
                            <label>中文名称</label>
                            <input type="text" placeholder="请输入角色名称" name="title" class="form-control">
                        </div>
                        <div class="form-group">
                            <label>英文标识</label>
                            <input type="text" placeholder="请输入角色的英文标识" name="name" class="form-control">
                        </div>

                    @endcomponent


                </div>
            </div>
            <div class="card-body">
                <table class="table table-sm table-striped">
                    <thead>
                    <tr>
                        <th>编号</th>
                        <th>中文名称</th>
                        <th>英文标识</th>
                        <th>操作时间</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>

                    @foreach($roles as $k=>$v)
                        <tr>
                            <td>{{$v['id']}}</td>
                            <td>{{$v['title']}}</td>
                            <td>{{$v['name']}}</td>
                            <td>{{$v['created_at']}}</td>
                            <td>
                                <button data-toggle="modal" data-target="#editrole{{$v['id']}}" type='button' class="btn btn-primary">
                                    编辑
                                </button>


                                <form style="display: inline" action="/admin/role/{{$v['id']}}" method="post">
                                    @csrf
                                    @method('DELETE')
                                    <button  class="btn btn-success">
                                        删除
                                    </button>
                                </form>


                                {{--给用户分配权限--}}
                                <a href="{{route('fenpei',$v['id'])}}" class="btn btn-dark">分配权限</a>
                                @component("components.modal",['title'=>'编辑角色','url'=>'/admin/role/'.$v['id'],'id'=>'editrole'.$v['id'],'method'=>'PUT'])
                                    <div class="form-group">
                                        <label>中文名称</label>
                                        <input type="text" value="{{$v['title']}}" name="title" class="form-control">
                                    </div>
                                    <div class="form-group">
                                        <label>英文标识</label>
                                        <input type="text" value="{{$v['name']}}" name="name" class="form-control">
                                    </div>
                                @endcomponent



                            </td>

                        </tr>
                    @endforeach
                    </tbody>
                </table>
            </div>
        </div>



    </div>




@endsection